package cn.kgc.mushroomdatabaseprovider.service.serviceimpl;

import cn.kgc.mushroomcommon.pojo.Address;
import cn.kgc.mushroomdatabaseprovider.mapper.AddressMapper;
import cn.kgc.mushroomdatabaseprovider.service.AddressService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional(readOnly = true)
public class AddressServiceImpl implements AddressService {
    @Resource
    AddressMapper addressMapper;


    @Override
    public List<Address> selectAddressListByView(Integer uidaddress) {
        return addressMapper.selectAddressListByView(uidaddress);
    }

    @Override
    @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
    public int insertaddress(Address address) {
         int insertaddress = addressMapper.insertaddress(address);
        return insertaddress;
    }

    @Override
    @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
    public int deleteaddress(Integer id) {
        return addressMapper.deleteaddress(id);
    }

    @Override
    @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
    public int updateaddresss(Integer id) {

        return addressMapper.updateaddresss(id);
    }

    @Override
    public Address selectByStatus(Integer status) {
         Address address = addressMapper.selectByStatus(status);
        return address;
    }

    @Override
    @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
    public int updatemoren(Integer id) {
         int updatemoren = addressMapper.updatemoren(id);
        return updatemoren;
    }
}
